/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sdc.event;

import sdc.strategy.proposal.ProposalStrategy;
import sdc.net.server.appli.ApplicationServer;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import sdc.Address;
import sdc.component.type.ComponentType;
import sdc.net.server.comp.ComponentServerManager;
import sdc.net.server.appli.ApplicationServerManager;

/**
 *
 * @author masa
 */
public class ProposalEvent extends Event{

    //private List<ComponentType> firstTypeList;

    private int serverNum;

    private final double t = 50.0;

    public ProposalEvent(double eventTime,int serverNum){
        super(eventTime);
        this.serverNum = serverNum;
    }

    @Override
    public void fire(){
        List<ApplicationServer> appList = ApplicationServerManager.INSTANCE.getShuffledList();
        for(ApplicationServer app : appList){
            Map<ComponentType,Address> nextMap = app.getUseComponentMap();
            for(Entry<ComponentType,Address> entry : nextMap.entrySet()){
                new ProposalStrategy().method(ComponentServerManager.INSTANCE.get(entry.getValue()), entry.getKey());
            }
        }
        EventQueue eq = EventQueue.INSTANCE;
        eq.addEvent(new ProposalEvent(eq.getCurrentTime() + t, serverNum));
    }
}
